﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace Dataglot
{
    public class NameUtils
    {
        
        public static string SplitParameterWordsWithUnderscore(string name)
        {
            if ((new DbConfigUtils()).SplitParameterWordsWithUnderscore())
            {
                StringBuilder sb = new StringBuilder();
                int i = 0;
                foreach (char c in name)
                {

                    if (c.ToString() == c.ToString().ToUpper())
                    {
                        if (i != 0)
                        {
                            sb.Append("_");
                        }
                        sb.Append(c.ToString().ToLower());
                        i++;
                    }
                    else
                    {
                        sb.Append(c);
                    }
                }

                return sb.ToString().ToLower();
            }
            return name;
        }

        public static  string ConvertToCSharp(string name)
        {
            name = name.Replace("_", " ");
            TextInfo ti = new CultureInfo("en-US").TextInfo;

            name = ti.ToTitleCase(name);
            name = name.Replace(" ", "");
            return name;
        }
    }
}
